<!DOCTYPE html>
<html lang="en">

<!-- Head tag -->
<head><meta name="generator" content="Hexo 3.8.0">

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!--Description-->
    
        <meta name="description" content="欢迎！">
    

    <!--Author-->
    
        <meta name="author" content="fafa">
    

    <!--Open Graph Title-->
    
        <meta property="og:title" content="Run-Fa Zhang&#39;s Site">
    

    <!--Open Graph Description-->
    
        <meta property="og:description" content="欢迎！">
    

    <!--Open Graph Site Name-->
    <meta property="og:site_name" content="Run-Fa Zhang&#39;s Site">

    <!--Type page-->
    
        <meta property="og:type" content="website">
    

    <!--Page Cover-->
    

    <meta name="twitter:card" content="summary">
    

    <!-- Title -->
    
    <title>Run-Fa Zhang&#39;s Site</title>

    <!-- Bootstrap Core CSS -->
    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" integrity="sha384-y3tfxAZXuh4HwSYylfB+J125MxIs6mR5FOHamPBG064zB+AFeWH94NdvaCBm8qnd" crossorigin="anonymous">

    <!-- Custom Fonts -->
    <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" type="text/css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="//oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="//oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

    <!-- Gallery -->
    <link href="//cdnjs.cloudflare.com/ajax/libs/featherlight/1.3.5/featherlight.min.css" type="text/css" rel="stylesheet">

    <!-- Custom CSS -->
    <link rel="stylesheet" href="/css/style.css">

    <!-- Google Analytics -->
    


</head>


<body>

<div class="bg-gradient"></div>
<div class="bg-pattern"></div>

<!-- Menu -->
<!--Menu Links and Overlay-->
<div class="menu-bg">
    <div class="menu-container">
        <ul>
            
            <li class="menu-item">
                <a href="/">
                    Home
                </a>
            </li>
            
            <li class="menu-item">
                <a href="/archives">
                    Archives
                </a>
            </li>
            
            <li class="menu-item">
                <a href="/about.html">
                    About
                </a>
            </li>
            
            <li class="menu-item">
                <a href="/tags">
                    Tags
                </a>
            </li>
            
            <li class="menu-item">
                <a href="/categories">
                    Categories
                </a>
            </li>
            
            <li class="menu-item">
                <a href="/contact.html">
                    Contact
                </a>
            </li>
            
        </ul>
    </div>
</div>

<!--Hamburger Icon-->
<nav>
    <a href="#menu"></a>
</nav>

<div class="container">

    <!-- Main Content -->
    <div class="row">
    <div class="col-sm-12">

        <!--Title and Logo-->
        <header>
    <div class="logo">
        <a href="/"><i class="logo-icon fa fa-cube" aria-hidden="true"></i></a>
        
    </div>
</header>

        <section class="main">
            
<div class="post">

    <div class="post-header">
        <h1 class="title">
            <a href="/2019/05/20/user-17163699-1558319415/Python/自动判分系统/">
                Untitled
            </a>
        </h1>
        <div class="post-info">
            
                <span class="date">2019-05-20</span>
            
            
            
        </div>
    </div>

    <div class="content">

        <!-- Gallery -->
        

        <!-- Post Content -->
        <!DOCTYPE html>
<html lang="en">
  <head><meta name="generator" content="Hexo 3.8.0">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>自动判分系统</title>
    <style type="text/css" media="all">
      body {
        margin: 0;
        font-family: "Helvetica Neue", Helvetica, Arial, "Hiragino Sans GB", sans-serif;
        font-size: 14px;
        line-height: 20px;
        color: #777;
        background-color: white;
      }
      .container {
        width: 700px;
        margin-right: auto;
        margin-left: auto;
      }

      .post {
        font-family: Georgia, "Times New Roman", Times, "SimSun", serif;
        position: relative;
        padding: 70px;
        bottom: 0;
        overflow-y: auto;
        font-size: 16px;
        font-weight: normal;
        line-height: 25px;
        color: #515151;
      }

      .post h1{
        font-size: 50px;
        font-weight: 500;
        line-height: 60px;
        margin-bottom: 40px;
        color: inherit;
      }

      .post p {
        margin: 0 0 35px 0;
      }

      .post img {
        border: 1px solid #D9D9D9;
      }

      .post a {
        color: #28A1C5;
      }
    </style>
  </head>
  <body>
    <div class="container">
      <div class="post">
        <h1 class="title">自动判分系统</h1>
        <div class="show-content">
          <blockquote>
<p>#目标是按照队员最高分数计入为 队伍分数<br>#首先是我们的数据集 来自腾讯微云<br>#<a href="https://share.weiyun.com/5ov0DKt" target="_blank">https://share.weiyun.com/5ov0DKt</a><br>#下载好之后直接把两个文件放入D盘即可，然后直接复制下面的内容就OK啦</p>
<p>####查看某列中的答案长什么样子(以便一会制作标准答案 来判分)####<br>import pandas as pd<br>import numpy as np<br>data=pd.read_excel('D:/编程大赛B题.xls',header=0)<br>aa=data["编程2"][0]<br>aa</p>
<p>####统计A卷的得分###############<br>import pandas as pd<br>import numpy as np<br>data=pd.read_excel('D:/编程大赛A题.xls',header=0)</p>
<p>#或者可以选择路径（如下）<br>#data=pd.read_csv('D:/D/1.csv',header=0) <br>#data=pd.read_csv('C:/Users/fafa/1.csv',header=0)</p>
<p>#定义 得分 函数：<br>def score(a):<br>    s=0<br>    if a[3]=="C":  #第一列的正确答案<br>        s+=10        #第一列的分值<br>    if a[4]=="D":  #第二列的正确答案<br>        s+=10       #第二列的分值<br>    if a[5]=="C": #第三列的正确答案<br>        s+=10        #第三列的分值 <br>    if a[6]=="B": #第四列的正确答案<br>        s+=10      #第四列的分值 <br>    if a[7]=="A": #第五列的正确答案<br>        s+=10    #第五列的分值 <br>    if len(str(a[8]).split(","))==5:  #填空题按照逗号分割后选择有5个元素的继续判断<br>        if str(a[8]).split(",")[0] in "流程线,起止框,输入输出框,判断框,处理框": #第五列的正确答案<br>            s+=10    #第五列的分值 <br>        if str(a[8]).split(",")[1] in "流程线,起止框,输入输出框,判断框,处理框": #第五列的正确答案           <br>            s+=10    #第五列的分值<br>        if str(a[8]).split(",")[2] in "流程线,起止框,输入输出框,判断框,处理框": #第五列的正确答案           <br>            s+=10    #第五列的分值<br>        if str(a[8]).split(",")[3] in "流程线,起止框,输入输出框,判断框,处理框": #第五列的正确答案           <br>            s+=10    #第五列的分值<br>        if str(a[8]).split(",")[4] in "流程线,起止框,输入输出框,判断框,处理框": #第五列的正确答案           <br>            s+=10    #第五列的分值<br>    return s</p>
<p>#增加一列"得分"<br>data["得分"]=[score(data.iloc[i]) for i in range(len(data.index))]<br><br>#按照max得分统计队伍<br>data2=data.groupby(["队伍名称"],as_index=False)["得分"].max()<br>#按照sum得分统计队伍<br>#data2=data.groupby(["队伍"],as_index=False)["得分"].sum()</p>
<p>#按照 个数 统计 队伍<br>#data.groupby(["队伍"]).size()<br><br>#改名字<br>data3=data2.rename(columns={"队伍":"队伍名称","得分":"赛题A最终分数"})<br><br>#拍序（按照最终分数）<br>dataA=data3.sort_values(by="赛题A最终分数",ascending=False)<br>dataA<br>##########################################至此就结束了#########################################</p>
<p>####统计B卷的得分###############<br>import pandas as pd<br>import numpy as np<br>data=pd.read_excel('D:/编程大赛B题.xls',header=0) <br>#定义 得分 函数：<br>def score(a):<br>    s=0 <br>    if a[3]=="x=input()\nx=int(x)\nif x&gt;=60:\n    y=\"及格\"\nelse:\n    y=\"不及格\"\nprint(y)": #第一列的正确答案 <br>        s+=50 #第一列的分值 <br>    if a[4]=="x=input()\nx=int(x)\nif x&gt;0:\n    y=\"正\"\nelse:\n    y=\"负\"\nprint(y)": #第二列的正确答案 <br>         s+=50 #第二列的分值 <br>    return s<br>#增加一列"得分"<br>data["得分"]=[score(data.iloc[i]) for i in range(len(data.index))]#按照max得分统计队伍<br>data2=data.groupby(["队伍名称"],as_index=False)["得分"].max()#按照sum得分统计队伍 <br>#改名字<br>data3=data2.rename(columns={"队伍":"队伍名称","得分":"赛题B最终分数"})<br> #拍序（按照最终分数）<br>dataB=data3.sort_values(by="赛题B最终分数",ascending=False)<br>dataB<br>##############################################至此就结束############################################ <br><br>#############后面的内容是如何关联多张成绩单，然后求和排名#########<br>#按照“”队伍名称”关联多个表格<br>dataD=pd.merge(dataA,dataB,on="队伍名称",how="outer")<br><br>#增加一列总分<br>dataD["总分"]=dataD.sum(axis=1)<br> #排序（按照最终分数） <br>dataD=dataD.sort_values(by="总分",ascending=False) <br>dataD</p>
</blockquote><div class="image-package">
<img name src="http://upload-images.jianshu.io/upload_images/17163699-bf7e96f94e1f780f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240"><br><div class="image-caption"></div>
</div><div class="image-package">
<img name src="http://upload-images.jianshu.io/upload_images/17163699-02bd4ef8649425b1.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240"><br><div class="image-caption">合并队伍，并选出该队队员最高分作为最终队伍成绩。</div>
</div><p>合并队伍，并选出该队队员最高分作为最终队伍成绩。</p><p><br></p><hr><p>关联两个表格</p><div class="image-package">
<img name src="http://upload-images.jianshu.io/upload_images/17163699-ddb6645f9f61c33b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240"><br><div class="image-caption">关联两个表格</div>
</div><hr id="null"><p>##################################################################################</p><p>###################以下内容就是其他的一些小技巧啦，和这个没有关系啦################</p><p>##############按列求和##########</p><p>data4.eval("总分 = 分数A+2*分数B",inplace=True)</p><p>#inplace参数表示是否在原数据上操作inplace=False将会生成新的DataFrame</p><p>#方法2</p><p>data4['总分'] = data4.apply(lambda x:x['分数A']+2*x['分数B'],axis=1)</p><p>data4</p><p>###################条件查询########</p><p>data4.query("分数A&gt;1")</p><p>data4</p><hr id="null"><p><br></p><p>If you are interested in this topic.﻿<br>You can get in touch with me.﻿<br>18234056952(Tel  wechat  qq)</p>
        </div>
      </div>
    </div>
  </body>
</html>

    </div>

    

    

    <!-- Comments -->
    

</div>
        </section>

    </div>
</div>


</div>

<!-- Footer -->
<div class="push"></div>

<footer class="footer-content">
    <div class="container">
        <div class="row">
            <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 footer-about">
                <h2>About</h2>
                <p>
                    This theme was developed by <a href="https://github.com/klugjo">Jonathan Klughertz</a>. The source code is available on Github. Create Websites. Make Magic.
                </p>
            </div>
            
    <div class="col-xs-6 col-sm-6 col-md-3 col-lg-3 recent-posts">
        <h2>Recent Posts</h2>
        <ul>
            
            <li>
                <a class="footer-post" href="/2019/05/20/user-17163699-1558319415/量子科学/量子算法/">Untitled</a>
            </li>
            
            <li>
                <a class="footer-post" href="/2019/05/20/user-17163699-1558319415/数学建模/建模/">Untitled</a>
            </li>
            
            <li>
                <a class="footer-post" href="/2019/05/20/user-17163699-1558319415/操作系统/Win10自带linux子系统/">Untitled</a>
            </li>
            
            <li>
                <a class="footer-post" href="/2019/05/20/user-17163699-1558319415/其他/Markdown/">Untitled</a>
            </li>
            
        </ul>
    </div>



            
        </div>
        <div class="row">
            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                <ul class="list-inline footer-social-icons">
                    
                    <li class="list-inline-item">
                        <a href="https://github.com/klugjo/hexo-theme-alpha-dust">
                            <span class="footer-icon-container">
                                <i class="fa fa-github"></i>
                            </span>
                        </a>
                    </li>
                    
                    
                    <li class="list-inline-item">
                        <a href="https://twitter.com/?lang=en">
                            <span class="footer-icon-container">
                                <i class="fa fa-twitter"></i>
                            </span>
                        </a>
                    </li>
                    
                    
                    <li class="list-inline-item">
                        <a href="https://www.facebook.com/">
                            <span class="footer-icon-container">
                                <i class="fa fa-facebook"></i>
                            </span>
                        </a>
                    </li>
                    
                    
                    <li class="list-inline-item">
                        <a href="https://www.instagram.com/">
                            <span class="footer-icon-container">
                                <i class="fa fa-instagram"></i>
                            </span>
                        </a>
                    </li>
                    
                    
                    <li class="list-inline-item">
                        <a href="https://dribbble.com/">
                            <span class="footer-icon-container">
                                <i class="fa fa-dribbble"></i>
                            </span>
                        </a>
                    </li>
                    
                    
                    <li class="list-inline-item">
                        <a href="https://plus.google.com/">
                            <span class="footer-icon-container">
                                <i class="fa fa-google-plus"></i>
                            </span>
                        </a>
                    </li>
                    
                    
                    <li class="list-inline-item">
                        <a href="https://www.behance.net/">
                            <span class="footer-icon-container">
                                <i class="fa fa-behance"></i>
                            </span>
                        </a>
                    </li>
                    
                    
                    <li class="list-inline-item">
                        <a href="https://500px.com/">
                            <span class="footer-icon-container">
                                <i class="fa fa-500px"></i>
                            </span>
                        </a>
                    </li>
                    
                    
                    <li class="list-inline-item">
                        <a href="mailto:test@example.com">
                            <span class="footer-icon-container">
                                <i class="fa fa-envelope-o"></i>
                            </span>
                        </a>
                    </li>
                    
                    
                    <li class="list-inline-item">
                        <a href="\#">
                            <span class="footer-icon-container">
                                <i class="fa fa-rss"></i>
                            </span>
                        </a>
                    </li>
                    
                </ul>
            </div>
        </div>
        <div class="row">
            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                <div class="footer-copyright">
                    @Untitled. All right reserved | Design & Hexo <a href="http://www.codeblocq.com/">Jonathan Klughertz</a>
                </div>
            </div>
        </div>
    </div>
</footer>

<!-- After footer scripts -->

<!-- jQuery -->
<script src="//code.jquery.com/jquery-2.1.4.min.js"></script>

<!-- Tween Max -->
<script src="//cdnjs.cloudflare.com/ajax/libs/gsap/1.18.5/TweenMax.min.js"></script>

<!-- Gallery -->
<script src="//cdnjs.cloudflare.com/ajax/libs/featherlight/1.3.5/featherlight.min.js" type="text/javascript" charset="utf-8"></script>

<!-- Custom JavaScript -->
<script src="/js/main.js"></script>

<!-- Disqus Comments -->



</body>

</html>